FROM ubuntu:24.04

ENV USER=deploy
ENV PASSWD=deploy
ENV WORKDIR=projects

# 安装开发环境必要的包
RUN apt-get update \
  && apt-get install -y ssh openssh-server build-essential \
    gcc g++ gdb gdbserver cmake \
    # net-tools 提供了ifconfig
    net-tools tar rsync \
    sudo \
  && apt-get clean

# 添加用户并配置密码
RUN useradd -m ${USER} && yes ${PASSWD} | passwd ${USER}

# 赋予sudo权限并允许无密码sudo
RUN echo ${USER}' ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN chmod 644 /etc/sudoers

COPY "id_rsa.pub" "/home/ssh_key.pub"

# CMD ["/usr/sbin/sshd", "-D"]

USER ${USER}
RUN mkdir -p /home/${USER}/${WORKDIR}/
ENV LC_ALL C.UTF-8